| Server IP : 121.121.20.254 / Your IP : 216.73.216.133 Web Server : Microsoft-IIS/10.0 System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64 User : IUSR ( 0) PHP Version : 8.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Program Files/LibreOffice/help/en-US/text/sbasic/shared/03/ |
Upload File : |
<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<base href="../../../../../">
<noscript><meta http-equiv="refresh" content="0; URL=../../../../../en-US/noscript.html"></noscript>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>SFDocuments.Base service</title>
<link rel="shortcut icon" href="media/navigation/favicon.ico">
<link type="text/css" href="normalize.css" rel="Stylesheet">
<link type="text/css" href="prism.css" rel="Stylesheet">
<link type="text/css" href="default.css" rel="Stylesheet">
<script type="text/javascript" src="polyfills.js"></script><script type="text/javascript" src="languages.js"></script><script type="text/javascript" src="en-US/langnames.js"></script><script type="text/javascript" src="flexsearch.debug.js"></script><script type="text/javascript" src="prism.js"></script><script type="text/javascript" src="help2.js" defer></script><script type="text/javascript" src="a11y-toggle.js" defer></script><script type="text/javascript" src="paginathing.js" defer></script><script type="text/javascript" src="en-US/bookmarks.js" defer></script><script type="text/javascript" src="en-US/contents.js" defer></script><script type="text/javascript" src="help.js" defer></script><meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
<header id="TopLeftHeader"><a class="symbol" href="en-US/text/shared/05/new_help.html"><div></div></a><a class="logo" href="en-US/text/shared/05/new_help.html"><p dir="auto">LibreOffice 24.2 Help</p></a><div class="dropdowns"><div class="modules">
<button type="button" data-a11y-toggle="modules-nav" id="modules" aria-haspopup="true" aria-expanded="false" aria-controls="modules-nav">Module</button><nav id="modules-nav" hidden=""></nav>
</div></div></header><aside class="leftside"><input id="accordion-1" name="accordion-menu" type="checkbox"><label for="accordion-1" dir="auto">Contents</label><div id="Contents" class="contents-treeview"></div></aside><div id="SearchFrame"><div id="Bookmarks">
<input id="search-bar" type="search" class="search" placeholder="Search in bookmarks for chosen module" dir="auto"><div class="nav-container" tabindex="0"><nav class="index" dir="auto"></nav></div>
</div></div>
<div id="DisplayArea" itemprop="softwareHelp" itemscope="true" itemtype="http://schema.org/SoftwareApplication">
<a name="abstract"></a>
<a name="bm_id41582391760252"></a>
<meta itemprop="keywords" content="Base service">
<h1 id="bm_id781582391760253" dir="auto">
<a name="BaseService"></a><span class="literal">SFDocuments</span>.<span class="literal">Base</span> service</h1>
<p id="par_id901619031958273" class="paragraph" dir="auto">The <span class="literal">Base</span> service provides a number of methods and properties to facilitate the management and handling of LibreOffice Base documents.</p>
<p id="par_id961619032060880" class="paragraph" dir="auto">This service is closely related to the <span class="literal">Document</span> service, which provides generic methods for handling LibreOffice documents, including Base documents. Hence, the <span class="literal">Base</span> service extends the <span class="literal">Document</span> service and provides additional methods that are specific for Base documents, enabling users to:</p>
<ul itemprop="Unordered" itemscope="true" itemtype="http://schema.org/ItemList" dir="auto">
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id241619032289964" class="listitem" dir="auto">Get access to the database contained in a Base document.</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id291619032292829" class="listitem" dir="auto">Open form documents stored in a Base document.</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id421619032296454" class="listitem" dir="auto">Check if a form document from a Base document is currently loaded.</p>
</li>
</ul>
<div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id241619032941497" dir="auto">Refer to the <a target="_top" href="en-US/text/sbasic/shared/03/sf_document.html"><span class="literal">Document</span> service</a> to learn more about methods and properties that can be used to manage LibreOffice documents.</p></div>
</div>
<br>
<h2 id="hd_id581582885621841" dir="auto">Service invocation</h2>
<p id="par_id141609955500101" class="paragraph" dir="auto">Before using the <span class="literal">Base</span> service the <span class="literal">ScriptForge</span> library needs to be loaded or imported:</p>
<div class="embedded">
<a name="importLibs"></a>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id901528999850603" dir="auto">• Basic macros require to load <span class="literal">ScriptForge</span> library using the following statement:<br><span class="literal">GlobalScope.BasicLibraries.loadLibrary("ScriptForge")</span><br><br>• Python scripts require an import from <span class="literal">scriptforge</span> module:<br><span class="literal">from scriptforge import CreateScriptService</span>
</p></div>
</div>
<br>
</div>
<div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
<p id="par_id311619033224680" class="paragraph" dir="auto">The Base service can be invoked in a variety of ways. The code snippet below uses the method <span class="literal">CreateBaseDocument</span> from the <span class="literal">UI</span> service to create a new Base file.</p>
<p id="par_id101619033666470" class="paragraph" dir="auto">Note that in all examples the object <span class="literal">oDoc</span> is an instance of the <span class="literal">Base</span> service.</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim ui As Object, oDoc As Object
Set ui = CreateScriptService("UI")
Set oDoc = ui.CreateBaseDocument("C:\Documents\MyFile.odb")
</code></pre></div>
<p id="par_id281619033570656" class="paragraph" dir="auto">The <span class="literal">Base</span> service can also be instantiated while opening an existing Base file, as shown below:</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
Set oDoc = ui.OpenBaseDocument("C:\Documents\MyFile.odb")
</code></pre></div>
<p id="par_id331619033713781" class="paragraph" dir="auto">If a Base document is already open, it is possible to instantiate the <span class="literal">Base</span> service directly:</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim oDoc As Object
Set oDoc = CreateScriptService("SFDocuments.Document", "MyFile.odb")
</code></pre></div>
<div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
<p id="par_id871623102536956" class="paragraph" dir="auto">The examples above can be translated to Python as follows:</p>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
from scriptforge import CreateScriptService
ui = CreateScriptService("UI")
doc = ui.CreateBaseDocument(r"C:\Documents\MyFile.odb")
</code></pre></div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
doc = ui.OpenBaseDocument(r"C:\Documents\MyFile.odb")
</code></pre></div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
doc = CreateScriptService("SFDocuments.Document", "MyFile.odb")
</code></pre></div>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id281619619980185" dir="auto">The use of the <span class="emph">"SFDocuments."</span> substring in the previous example is optional.</p></div>
</div>
<br>
<a name="methods_toc"></a>
<table border="1" class="" cellpadding="0" cellspacing="0">
<tr>
<th rowspan="" colspan="3" class="tableheadcell" dir="auto">
<p id="par_id451619034669263" class="tableheadintable" dir="auto">List of Methods in the Base Service</p>
</th>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id981619034669263" class="tablecontentintable" dir="auto">
<a target="_top" href="en-US/text/sbasic/shared/03/sf_base.html#CloseFormDocument">CloseFormDocument</a><br>
<a target="_top" href="en-US/text/sbasic/shared/03/sf_base.html#FormDocuments">FormDocuments</a><br>
<a target="_top" href="en-US/text/sbasic/shared/03/sf_base.html#Forms">Forms</a><br>
<a target="_top" href="en-US/text/sbasic/shared/03/sf_base.html#GetDatabase">GetDatabase</a>
</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id721619034669263" class="tablecontentintable" dir="auto">
<a target="_top" href="en-US/text/sbasic/shared/03/sf_base.html#IsLoaded">IsLoaded</a><br>
<a target="_top" href="en-US/text/sbasic/shared/03/sf_base.html#OpenFormDocument">OpenFormDocument</a><br>
<a target="_top" href="en-US/text/sbasic/shared/03/sf_base.html#OpenQuery">OpenQuery</a><br>
<a target="_top" href="en-US/text/sbasic/shared/03/sf_base.html#OpenTable">OpenTable</a>
</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id711619034669263" class="tablecontentintable" dir="auto">
<a target="_top" href="en-US/text/sbasic/shared/03/sf_base.html#PrintOut">PrintOut</a><br>
<a target="_top" href="en-US/text/sbasic/shared/03/sf_base.html#SetPrinter">SetPrinter</a><br><br><br>
</p>
</td>
</tr>
</table>
<br>
<a name="CloseFormDocument"></a>
<a name="bm_id341609135528912"></a>
<meta itemprop="keywords" content="Base service,CloseFormDocument">
<h2 id="hd_id61161309632927" dir="auto">CloseFormDocument</h2>
<p id="par_id801916099743199" class="paragraph" dir="auto">Closes the given form document. Returns <span class="literal">True</span> if closure is successful.</p>
<div class="warning">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/warning.svg" alt="warning" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id81692554166441" dir="auto">The method <span class="literal">CloseFormDocument</span> is deprecated since LibreOffice 7.6. Although it is still available, it may be removed from the <span class="literal">Base</span> service in a future release. Use the <span class="literal">CloseDocument</span> method from the <span class="literal">FormDocument</span> service instead.</p></div>
</div>
<br>
<div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
<p id="par_id71613205516650" class="paragraph" dir="auto">
<span class="input" data-tooltip="Click on text to copy to clipboard">svc.CloseFormDocument(formdocument: str): bool</span>
</p>
<div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
<p id="par_id941619079997810" class="paragraph" dir="auto"><span class="emph">formdocument:</span> The name of the <span class="literal">FormDocument</span> to be closed, as a case-sensitive string.</p>
<div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
<p id="par_id351619100723505" class="paragraph" dir="auto">If form documents are organized in folders, it is necessary to include the folder name to specify the form document to be opened, as illustrated in the following examples:</p>
<div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
oDoc.CloseFormDocument("Folder1/myFormDocument")
</code></pre></div>
<div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
doc.CloseFormDocument('Folder1/myFormDocument')
</code></pre></div>
<a name="FormDocuments"></a>
<a name="bm_id401619035409457"></a>
<meta itemprop="keywords" content="Base service,FormDocuments">
<h2 id="hd_id841619035592745" dir="auto">FormDocuments</h2>
<p id="par_id481619036833610" class="paragraph" dir="auto">Returns an array with the full names (path/name) of all form documents in the Base document as a zero-based Array of strings.</p>
<div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
<p id="par_id401623103182304" class="paragraph" dir="auto">
<span class="input" data-tooltip="Click on text to copy to clipboard">svc.FormDocuments(): str[0..*]</span>
</p>
<div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
<p id="par_id431619037334440" class="paragraph" dir="auto">The code snippet below prints the names of all form documents in the current Base document.</p>
<div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim oDoc as Object, myForms as Object, formName as String
Set oDoc = CreateScriptService("Document", ThisDataBaseDocument)
Set myForms = oDoc.FormDocuments()
For Each formName In myForms
MsgBox formName
Next formName
</code></pre></div>
<div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
bas = CreateScriptService("Basic")
doc = CreateScriptService("Document", bas.ThisDataBaseDocument)
myForms = doc.FormDocuments()
for formName in myForms:
bas.MsgBox(formName)
</code></pre></div>
<div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id921619036922844" dir="auto">To learn more about form documents, refer to the <a target="_top" href="en-US/text/sbasic/shared/03/sf_form.html"><span class="literal">Form</span> service help page</a>.</p></div>
</div>
<br>
<a name="Forms"></a>
<a name="bm_id861619035438484"></a>
<meta itemprop="keywords" content="Base service,Forms">
<h2 id="hd_id291619035603979" dir="auto">Forms</h2>
<p id="par_id191619037523467" class="paragraph" dir="auto">Depending on the parameters provided this method will return:</p>
<ul itemprop="Unordered" itemscope="true" itemtype="http://schema.org/ItemList" dir="auto">
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id781619037575043" class="listitem" dir="auto">A zero-based Array with the names of all the forms contained in a form document (if the <span class="literal">Form</span> argument is absent)</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id111619037577804" class="listitem" dir="auto">A <span class="literal">SFDocuments.Form</span> object representing the form specified in the <span class="literal">Form</span> argument.</p>
</li>
</ul>
<div class="warning">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/warning.svg" alt="warning" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id81692554166191" dir="auto">The method <span class="literal">Forms</span> is deprecated since LibreOffice 7.6. Although it is still available, it may be removed from the <span class="literal">Base</span> service in a future release. Use the <span class="literal">Forms</span> method from the <span class="literal">FormDocument</span> service instead.</p></div>
</div>
<br>
<div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
<p id="par_id851623104561457" class="paragraph" dir="auto">
<span class="input" data-tooltip="Click on text to copy to clipboard">svc.Forms(formdocument: str): str[0..*]</span>
</p>
<p id="par_id851623104560857" class="paragraph" dir="auto">
<span class="input" data-tooltip="Click on text to copy to clipboard">svc.Forms(formdocument: str, form: str = ''): svc</span>
</p>
<p id="par_id851623104562213" class="paragraph" dir="auto">
<span class="input" data-tooltip="Click on text to copy to clipboard">svc.Forms(formdocument: str, form: int): svc</span>
</p>
<div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
<p id="par_id861619037838260" class="paragraph" dir="auto"><span class="emph">formdocument:</span> The name of a valid form document as a case-sensitive string.</p>
<p id="par_id281619037857187" class="paragraph" dir="auto"><span class="emph">form:</span> The name or index number of the form stored in the form document. If this argument is absent, the method will return a list with the names of all forms available in the form document.</p>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id921619437863617" dir="auto">Although it is possible to use index numbers to refer to forms, this is only recommended when there is just one form in the form document. If there are two or more forms, it is preferable to use the form name instead.</p></div>
</div>
<br>
<div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
<p id="par_id21623104676805" class="paragraph" dir="auto">The first line of the example below returns a list of all forms in the form document "myFormDocument". The second line returns an instance of the Form service representing the form "myForm".</p>
<div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim formsList as Object : formsList = oDoc.Forms("myFormDocument")
Dim oForm as Object : oForm = oDoc.Forms("myFormDocument", "myForm")
</code></pre></div>
<div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
formsList = doc.Forms("myFormDocument")
form = doc.Forms("myFormDocument", "myForm")
</code></pre></div>
<a name="GetDatabase"></a>
<a name="bm_id301619035470065"></a>
<meta itemprop="keywords" content="Base service,GetDatabase">
<h2 id="hd_id111619035612996" dir="auto">GetDatabase</h2>
<p id="par_id371619098340303" class="paragraph" dir="auto">Returns an instance of the <a target="_top" href="en-US/text/sbasic/shared/03/sf_database.html"><span class="literal">Database</span> service</a> that allows the execution of SQL commands on the database defined and/or stored in the current Base document</p>
<div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
<p id="par_id431623105245851" class="paragraph" dir="auto">
<span class="input" data-tooltip="Click on text to copy to clipboard">svc.GetDatabase(user: str = '', password: str = ''): svc</span>
</p>
<div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
<p id="par_id731619098073221" class="paragraph" dir="auto"><span class="emph">user, password:</span> Optional login parameters as strings. The default value for both parameters is an empty string "".</p>
<div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
<div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim myDoc As Object, myDatabase As Object, ui As Object
Set ui = CreateScriptService("UI")
Set myDoc = ui.OpenBaseDocument("C:\Documents\myDb.odb")
' User and password are supplied below, if needed
Set myDatabase = myDoc.GetDatabase()
' ... Run queries, SQL statements, ...
myDatabase.CloseDatabase()
myDoc.CloseDocument()
</code></pre></div>
<div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
ui = CreateScriptService("UI")
myDoc = ui.OpenBaseDocument(r"C:\Documents\myDb.odb")
myDatabase = myDoc.GetDatabase()
# ... Run queries, SQL statements, ...
myDatabase.CloseDatabase()
myDoc.CloseDocument()
</code></pre></div>
<a name="IsLoaded"></a>
<a name="bm_id351619035498660"></a>
<meta itemprop="keywords" content="Base service,IsLoaded">
<h2 id="hd_id621619035622085" dir="auto">IsLoaded</h2>
<p id="par_id871619098478513" class="paragraph" dir="auto">Returns <span class="literal">True</span> if the specified <span class="literal">FormDocument</span> is currently open.</p>
<div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
<p id="par_id831623105309694" class="paragraph" dir="auto">
<span class="input" data-tooltip="Click on text to copy to clipboard">svc.IsLoaded(formdocument: str): bool</span>
</p>
<div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
<p id="par_id981619098545701" class="paragraph" dir="auto"><span class="emph">formdocument:</span> The name of a <span class="literal">FormDocument</span> to be checked, as a case-sensitive string.</p>
<div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
<div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
If Not oDoc.IsLoaded("myFormDocument") Then
oDoc.OpenFormDocument("myFormDocument")
End If
</code></pre></div>
<div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
if not doc.IsLoaded("myFormDocument"):
doc.OpenFormDocument("myFormDocument")
</code></pre></div>
<a name="OpenFormDocument"></a>
<a name="bm_id341619035528912"></a>
<meta itemprop="keywords" content="Base service,OpenFormDocument">
<h2 id="hd_id611619035632927" dir="auto">OpenFormDocument</h2>
<p id="par_id801619099743199" class="paragraph" dir="auto">Opens the specified <span class="literal">FormDocument</span> either in normal or in design mode. This method returns a <span class="literal">FormDocument</span> service instance corresponding to the specified form document.</p>
<p id="par_id451619100075330" class="paragraph" dir="auto">If the form document is already open, it is activated without changing its mode.</p>
<p id="par_id651692554712005" class="paragraph" dir="auto">If the specified form document does not exist, then <span class="literal">Nothing</span> is returned.</p>
<div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
<p id="par_id71623105516650" class="paragraph" dir="auto">
<span class="input" data-tooltip="Click on text to copy to clipboard">svc.OpenFormDocument(formdocument: str, designmode: bool = False): svc</span>
</p>
<div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
<p id="par_id941619099797810" class="paragraph" dir="auto"><span class="emph">formDocument:</span> The name of the <span class="literal">FormDocument</span> to be opened, as a case-sensitive string.</p>
<p id="par_id981619099816849" class="paragraph" dir="auto"><span class="emph">designmode:</span> If this argument is <span class="literal">True</span> the <span class="literal">FormDocument</span> will be opened in design mode.</p>
<div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
<div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
<p id="par_id251619100191992" class="paragraph" dir="auto">Most form documents are stored in the root of the Base document and they can be opened simply using their names, as in the example below:</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim oFormDoc As Object
oFormDoc = oDoc.OpenFormDocument("myFormDocument")
</code></pre></div>
<p id="par_id351619100327505" class="paragraph" dir="auto">If form documents are organized in folders, it becomes necessary to include the folder name to specify the form document to be opened, as illustrated in the following example:</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
oFormDoc = oDoc.OpenFormDocument("myFolder/myFormDocument")
</code></pre></div>
<div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
formDoc = doc.OpenFormDocument("myFormDocument")
</code></pre></div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
formDoc = doc.OpenFormDocument("myFolder/myFormDocument")
</code></pre></div>
<a name="OpenQuery"></a>
<a name="bm_id781599490609222"></a>
<meta itemprop="keywords" content="Base Service,OpenQuery">
<h2 id="hd_id80159949060014" dir="auto">OpenQuery</h2>
<p id="par_id31599490604484" class="paragraph" dir="auto">Opens the Data View window of the specified query and returns an instance of the <span class="literal">Datasheet</span> service.</p>
<p id="par_id281671113374329" class="paragraph" dir="auto">The query can be opened either in normal or design mode.</p>
<p id="par_id801671111609985" class="paragraph" dir="auto">If the query is already open, its Data View window will be made active.</p>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id521671113436716" dir="auto">Closing the Base document will cause the Data View window to be closed as well.</p></div>
</div>
<br>
<div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
<p id="par_id421625701780171" class="paragraph" dir="auto">
<span class="input" data-tooltip="Click on text to copy to clipboard">svc.OpenQuery(queryname: str, designmode: bool = False): obj</span>
</p>
<div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
<p id="par_id701599490609511" class="paragraph" dir="auto"><span class="emph">queryname</span>: The name of an existing query as a case-sensitive String.</p>
<p id="par_id461671113939669" class="paragraph" dir="auto"><span class="emph">designmode</span>: If this argument is set to <span class="literal">True</span> the query is opened in design mode. Otherwise it is opened in normal mode (Default = <span class="literal">False</span>).</p>
<div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
<div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
oDoc.OpenQuery("MyQuery", DesignMode := True)
</code></pre></div>
<div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
doc.OpenQuery("MyQuery", designmode=True)
</code></pre></div>
<a name="OpenTable"></a>
<a name="bm_id78159949060145"></a>
<meta itemprop="keywords" content="Base Service,OpenTable">
<h2 id="hd_id80159949063922" dir="auto">OpenTable</h2>
<p id="par_id31599490604787" class="paragraph" dir="auto">Opens the Data View window of the specified table and returns an instance of the <span class="literal">Datasheet</span> service.</p>
<p id="par_id281671113374441" class="paragraph" dir="auto">The table can be opened either in normal or design mode.</p>
<p id="par_id801671111609395" class="paragraph" dir="auto">If the table is already open, its Data View window will be made active.</p>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id521671113436658" dir="auto">Closing the Base document will cause the Data View window to be closed as well.</p></div>
</div>
<br>
<div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
<p id="par_id421625701751251" class="paragraph" dir="auto">
<span class="input" data-tooltip="Click on text to copy to clipboard">svc.OpenTable(tablename: str, designmode: bool = False): obj</span>
</p>
<div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
<p id="par_id701599490609099" class="paragraph" dir="auto"><span class="emph">tablename</span>: The name of an existing table as a case-sensitive String.</p>
<p id="par_id461671113939471" class="paragraph" dir="auto"><span class="emph">designmode</span>: If this argument is set to <span class="literal">True</span> the table is opened in design mode. Otherwise it is opened in normal mode (Default = <span class="literal">False</span>).</p>
<div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
<div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
oDoc.OpenTable("MyTable", DesignMode = False)
</code></pre></div>
<div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
doc.OpenTable("MyTable", designmode=False)
</code></pre></div>
<a name="PrintOut"></a>
<a name="bm_id721985200121249"></a>
<meta itemprop="keywords" content="Base service,PrintOut">
<h2 id="hd_id261589202101415" dir="auto">PrintOut</h2>
<p id="par_id156589200121138" class="paragraph" dir="auto">This method sends the content of the given form document to a default printer or a printer defined by the <span class="literal">SetPrinter()</span> method.</p>
<p id="par_id981611169416934" class="paragraph" dir="auto">Returns <span class="literal">True</span> if the document was successfully printed.</p>
<div class="warning">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/warning.svg" alt="warning" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id81692554166367" dir="auto">The method <span class="literal">PrintOut</span> is deprecated since LibreOffice 7.6. Although it is still available, it may be removed from the <span class="literal">Base</span> service in a future release. Use the <span class="literal">PrintOut</span> method from the <span class="literal">FormDocument</span> service instead.</p></div>
</div>
<br>
<div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
<p id="par_id1001622827822169" class="paragraph" dir="auto">
<span class="input" data-tooltip="Click on text to copy to clipboard">svc.PrintOut(opt formdocument: str, pages: str = "", copies: num = 1): bool</span>
</p>
<div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
<p id="par_id368519200121646" class="paragraph" dir="auto"><span class="emph">formdocument</span>: A valid document form name as a case-sensitive string. The form document must be open. It is activated by the method.</p>
<p id="par_id211635436910093" class="paragraph" dir="auto"><span class="emph">pages</span>: The pages to print as a string, like in the user interface. Example: "1-4;10;15-18". Default is all pages.</p>
<p id="par_id141635436912146" class="paragraph" dir="auto"><span class="emph">copies</span>: The number of copies. Default is 1.</p>
<div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
<div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
If oDoc.PrintOut("myForm", "1-4;10;15-18", Copies := 2) Then
' ...
End If
</code></pre></div>
<div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
if doc.PrintOut('myForm', copies=3, pages='45-88'):
# ...
</code></pre></div>
<a name="SetPrinter"></a>
<a name="bm_id71158921504765"></a>
<meta itemprop="keywords" content="Base service,SetPrinter">
<h2 id="hd_id811589502147824" dir="auto">SetPrinter</h2>
<p id="par_id911298505147502" class="paragraph" dir="auto">Define the printer options for a form document. The form document must be open.</p>
<p id="par_id381651114800685" class="paragraph" dir="auto">Returns <span class="literal">True</span> when successful.</p>
<div class="warning">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/warning.svg" alt="warning" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id81692554166449" dir="auto">The method <span class="literal">SetPrinter</span> is deprecated since LibreOffice 7.6. Although it is still available, it may be removed from the <span class="literal">Base</span> service in a future release. Use the <span class="literal">SetPrinter</span> method from the <span class="literal">Document</span> service instead.</p></div>
</div>
<br>
<div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
<p id="par_id261652828596855" class="paragraph" dir="auto">
<span class="input" data-tooltip="Click on text to copy to clipboard">svc.SetPrinter(opt formdocument: str, opt printer: str, opt orientation: str, paperformat: str): bool</span>
</p>
<div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
<p id="par_id961635950394507" class="paragraph" dir="auto"><span class="emph">formdocument</span>: A valid document form name as a case-sensitive string.</p>
<div class="embedded">
<a name="setPrinterArgs"></a>
<p id="par_id301589205741697" class="paragraph" dir="auto"><span class="emph">printer</span>: The name of the printer queue where to print to. When absent, the default printer is set.</p>
<p id="par_id851985205147348" class="paragraph" dir="auto"><span class="emph">orientation</span>: Either <span class="literal">PORTRAIT</span> or <span class="literal">LANDSCAPE</span>. When absent, left unchanged with respect to the printer settings.</p>
<p id="par_id821985205147330" class="paragraph" dir="auto"><span class="emph">paperformat</span>: Specifies the paper format as a string value that can be either <span class="literal">A3</span>, <span class="literal">A4</span>, <span class="literal">A5</span>, <span class="literal">LETTER</span>, <span class="literal">LEGAL</span> or <span class="literal">TABLOID</span>. Left unchanged when absent.</p>
</div>
<div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
<div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
oDoc.SetPrinter("myForm", Orientation := "PORTRAIT")
</code></pre></div>
<div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
doc.SetPrinter('myForm', paperformat='TABLOID')
</code></pre></div>
<div class="embedded">
<a name="SF_InternalUse"></a>
<div class="warning">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/warning.svg" alt="warning" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id851506659675843" dir="auto">All <span class="literal">ScriptForge</span> Basic routines or identifiers that are prefixed with an underscore character "_" are reserved for internal use. They are not meant be used in Basic macros or Python scripts.</p></div>
</div>
<br>
</div>
<a name="relatedtopics"></a><div class="relatedtopics">
<p class="related" itemprop="mentions" dir="auto"><a name="related"></a><span class="emph">Related Topics</span>
</p>
<div class="relatedbody" itemprop="mentions">
<div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="en-US/text/sbasic/shared/03/sf_database.html"><span class="literal">SFDatabases</span>.<span class="literal">Database</span> service</a></p></div>
<div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="en-US/text/sbasic/shared/03/sf_document.html"><span class="literal">SFDocuments</span>.<span class="literal">Document</span> service</a></p></div>
<div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="en-US/text/sbasic/shared/03/sf_form.html"><span class="literal">SFDocuments</span>.<span class="literal">Form</span> service</a></p></div>
<div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="en-US/text/sbasic/shared/03/sf_ui.html"><span class="literal">ScriptForge</span>.<span class="literal">UI</span> service</a></p></div>
</div>
</div>
</div>
<div id="DonationFrame"></div>
<footer><div id="DEBUG" class="debug">
<h3 class="bug">Help content debug info:</h3>
<p dir="auto">This page is: <a href="https://opengrok.libreoffice.org/xref/help/source/text/sbasic/shared/03/sf_base.xhp" target="_blank">/text/sbasic/shared/03/sf_base.xhp</a></p>
<p dir="auto">Title is: SFDocuments.Base service</p>
<p id="bm_module" dir="auto"></p>
<p id="bm_system" dir="auto"></p>
<p id="bm_HID" dir="auto"></p>
</div></footer>
</body>
</html>